Skip to content

Unify the backend connect signature on one host-injected shape - #38

Open
aron-cf wants to merge 1 commit into
stack/3-process-shimfrom
stack/4-unify-connect-host
Open

Unify the backend connect signature on one host-injected shape#38
aron-cf wants to merge 1 commit into
stack/3-process-shimfrom
stack/4-unify-connect-host

Conversation

@aron-cf

@aron-cf aron-cf commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The two backend interfaces took different connect signatures. The shell and container kind took a bare connect() and reached the host through a transport it captured when it was built. The JavaScript kind took a connect(host) that received the storage-layer handles the Workspace owns. The split was historical rather than necessary: the host bag exists only because the Workspace builds its database and filesystem handles after the caller has already constructed the backends and passed them in, so a backend cannot capture them at its own construction time.

This change gives every backend the same connect(host) signature and has the Workspace pass its host bag on every connect. Shell and container backends accept the bag and ignore it, reaching the host through their own transport as before; the JavaScript backend uses it as before. Because method parameters are compatible when an implementation ignores arguments the interface declares, the existing zero-argument implementations satisfy the wider signature without edits. The duplicate host type collapses onto one canonical definition.

This is internal plumbing. connect is called only by the Workspace itself, never by an example or other consumer, so there is no public-API impact. No behavior changes.

Verify with npm test --workspace @cloudflare/computer and npm run typecheck.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/computer/@cloudflare/computer@38

commit: 741f0c9

The shell and module backend interfaces took different connect
signatures: the shell kind a bare connect(), the module kind a
connect(host) receiving the storage-layer handles the Workspace owns.
The split was historical, not necessary; the host bag exists only
because the Workspace builds db and fs after the caller constructs the
backends.

Give WorkspaceBackend.connect the same host parameter and pass the bag
on every connect. Shell and container backends ignore it and reach the
host through their own transport; the module backend uses it as before.
Method-parameter bivariance lets the existing zero-argument
implementations satisfy the wider signature unchanged. Collapse the
duplicate WorkspaceModuleBackendHost onto the canonical
WorkspaceBackendHost so there is one definition.
@aron-cf
aron-cf force-pushed the stack/4-unify-connect-host branch from 741f0c9 to 0653c4e Compare August 1, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant